import com.bw.pojo.Student;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/***************************
 FileAction:

 CreateTime:2022-05-11 14:55
 Author:Aaking-aline
 ****************************/
public class StudentDao {

	public List<Student> selectAllStudent() throws SQLException {
		String sql = "select * from student";

		Connection conn = JDBC.getConnection();

		PreparedStatement ps = conn.prepareStatement(sql);

		ResultSet rs = ps.executeQuery();

		List<Student> list = new ArrayList<>();

		while(rs.next()){
			Student student = new Student(rs.getInt(1), rs.getString(2), rs.getInt(3));
			list.add(student);
		}

		return list;
	}

}
